<template>
  <el-menu
    default-active="2"
    class="el-menu-vertical-demo"
    :default-active="defaultActive"
    @open="handleOpen"
    @close="handleClose"
    :collapse="!isCollapse"
    :router="true"
    background-color="rgb(48, 65, 86)"
    text-color="#fff"
    active-text-color="rgb(64, 158, 255)">
    <el-menu-item index="/admin" :class="isCollapse ? 'open' : 'fold'">
      <i class="iconfont icon-shouye"></i>
      <span slot="title">首页</span>
    </el-menu-item>
    <el-menu-item index="/admin/add" :class="isCollapse ? 'open' : 'fold'">
      <i class="iconfont icon-xinzeng"></i>
      <span slot="title">新增文章</span>
    </el-menu-item>
    <el-menu-item index="/admin/tag" :class="isCollapse ? 'open' : 'fold'">
      <i class="iconfont icon-biaoqian"></i>
      <span slot="title">标签管理</span>
    </el-menu-item>
  </el-menu>
</template>

<script>
export default {
  props: {
    isCollapse: {
      type: Boolean,
      require: true
    }
  },
  computed: {
    defaultActive () {
      return this.$route.path
    }
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    }
  }
}
</script>

<style lang="scss">
</style>
